def _impl_zip_rchive(ctx):
    archive_file = ctx.outputs.archive_file

    args = ctx.actions.args()
    args.add(archive_file)
    args.add_all(ctx.files.files)

    ctx.actions.run(
        executable = "zip",
        arguments  = [args],
        inputs     = ctx.files.files,
        outputs    = [archive_file]
    )

    return DefaultInfo(
        files = depset([archive_file]),
    )

zip_archive = rule(
    implementation = _impl_zip_rchive,
    attrs = {
        "files" : attr.label_list(allow_files=True),  # 要打包哪些文件
        "archive_file" : attr.output(mandatory=True), # 输出的压缩包名
    },
)